package com.csq.cms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csq.cms.service.ResumeService;
import com.csq.common.pojo.ReturnResult;
import com.csq.common.pojo.StatusCode;
import com.csq.manager.mapper.ResumeMapper;
import com.csq.manager.pojo.Resume;
import com.csq.manager.pojo.ResumeExample;
import com.csq.manager.pojo.ResumeExample.Criteria;

@Service
public class ResumeServiceImpl implements ResumeService {

	@Autowired
	private ResumeMapper resumeMapper;

	@Override
	public ReturnResult updateResume(Resume resume) {
		// TODO Auto-generated method stub

		int updateByPrimaryKeySelective = resumeMapper
				.updateByPrimaryKeySelective(resume);

		if (updateByPrimaryKeySelective == 0) {
			return ReturnResult.build(StatusCode.UPDATEFAIL, "更新失败");
		}

		return ReturnResult.ok();
	}

	@Override
	public Resume getResume(Integer accountId) {
		// TODO Auto-generated method stub

		ResumeExample example = new ResumeExample();

		Criteria createCriteria = example.createCriteria();
		createCriteria.andUserIdEqualTo(accountId);
		List<Resume> selectByExample = resumeMapper.selectByExample(example);

		if (selectByExample.size() != 0) {

			return selectByExample.get(0);
		}
		System.out.println("該用戶没有简历");
		return null;
	}

}
